#include <cstdio>
#include <cstdlib>
#include "vectclasses.hpp"
#include "classifyclasses.hpp"

int Classify::classifyOne(Vector & vector, VectorArray & classes)
{
    int classnum = classes.getVectNumber();
    Vector result(classnum);

    for (int i = 0; i < classnum; i++)
    {
        result.at(i) = vector.multiply(classes.getVector(i));
    }
    return result.maxPlace();

}

Vector Classify::classifyAll(VectorArray & vectors, VectorArray & classes)
{
    int vectnum = vectors.getVectNumber();
    Vector classresult(vectnum);

	FILE *fout;
	fout = fopen("output.txt","wt");
	for (int i = 0; i < vectnum; i++)
	{
		classresult.at(i) = classifyOne(vectors.getVector(i), classes);
		fprintf(fout, "Vector number %d belongs to the class number %d\n", i, classresult.at(i));
	}
    fclose(fout);
    return classresult;
}
